package com.xxxx.web.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xxxx.web.dto.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.time.LocalDateTime;

/**
 * 入库单表表
 */
@Data
@TableName("`StockIn`")
public class StockIn extends BaseEntity {


    /**
     * 入库状态枚举
     */
    @JsonProperty("StockInStatus")
    @TableField(value = "StockInStatus", updateStrategy = FieldStrategy.IGNORED)
    private Integer StockInStatus;

    /**
     * 备注
     */
    @JsonProperty("Remark")
    @TableField(value = "Remark", updateStrategy = FieldStrategy.IGNORED)
    private String Remark;

    /**
     * 入库类型枚举
     */
    @JsonProperty("StockInType")
    @TableField(value = "StockInType", updateStrategy = FieldStrategy.IGNORED)
    private Integer StockInType;

    /**
     * 计划入库时间
     */
    @JsonProperty("PlanInTime")
    @TableField(value = "PlanInTime", updateStrategy = FieldStrategy.IGNORED)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime PlanInTime;

    /**
     * 仓库
     */
    @JsonProperty("WarehouseId")
    @TableField(value = "WarehouseId", updateStrategy = FieldStrategy.IGNORED)
    private Integer WarehouseId;

    /**
     * 入库单号
     */
    @JsonProperty("No")
    @TableField(value = "No", updateStrategy = FieldStrategy.IGNORED)
    private String No;

    /**
     * 入库时间
     */
    @JsonProperty("InTime")
    @TableField(value = "InTime", updateStrategy = FieldStrategy.IGNORED)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime InTime;

    /**
     * 货主
     */
    @JsonProperty("CustomerId")
    @TableField(value = "CustomerId", updateStrategy = FieldStrategy.IGNORED)
    private Integer CustomerId;

    /**
     * 把入库单表实体转换成入库单表传输模型
     */
    public StockInDto MapToDto() throws InvocationTargetException, IllegalAccessException {
        StockInDto StockInDto = new StockInDto();

        BeanUtils.copyProperties(StockInDto, this);

        return StockInDto;
    }

}
